#include <opencv2/opencv.hpp>
#include <rclcpp/rclcpp.hpp>

namespace perception::camera {
class CameraInfo {
public:
    // 确认im_pts归一化 0<xy<1，输出坐标系 原点后车轮中心店，XYZ正方向为前左上
    void convert_uv2xy(const std::string &cam_name, const std::vector<cv::Point2f> &im_pts, std::vector<cv::Point2f> &ground_pts);
    static CameraInfo *get_inst();

    const std::string inex_dir_;
    const std::string roi_dir_;
    // decision::math::Polygon2d roi_3d_;
    bool valid_roi_3d_ = false;

    rclcpp::Logger logger_;


    std::map<std::string, cv::Matx<double, 3, 3>> cam_K_;
    std::map<std::string, cv::Matx<double, 1, 5>> cam_distort_;
    std::map<std::string, cv::Matx<double, 3, 3>> cam_c2g_; // camera to ground
    std::map<std::string, cv::Size> cam_calib_wh_ = 
        {
            {"camera0", cv::Size{3840, 2160}},
            {"camera1", cv::Size{3840, 2160}},
            {"camera2", cv::Size{1920, 1080}},
            {"camera3", cv::Size{1920, 1080}},
            {"camera4", cv::Size{1920, 1080}},
            {"camera5", cv::Size{1920, 1080}},
            {"camera6", cv::Size{1920, 1080}}
        };

private:
    CameraInfo(std::string inex_path, std::string roi_dir = "");
    static CameraInfo *cam_info_;
};
}